package com.zsw;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;

import com.zsw.recongize.frame.JFrame_;

@PropertySource("classpath:init.properties")
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ComponentScan(basePackages = "com.zsw")
@EnableAutoConfiguration
public class Main implements EmbeddedServletContainerCustomizer{
	
	@Value("${server.port}")
	private int port ;
	
	public static void main(String[] args) {
		String path = Main.class.getResource("").getPath();
		if(path.lastIndexOf(".jar") > 0){
			path = path.substring(0, path.lastIndexOf(".jar"));
		}
		path = path.substring(0, path.lastIndexOf("/"));
		System.setProperty("invoice.path", path);
		new JFrame_().setVisible(true);
		SpringApplication.run(Main.class);
	}

	@Override
	public void customize(ConfigurableEmbeddedServletContainer embed) {
		embed.setPort(port);
		embed.setSessionTimeout(3600);
		embed.setContextPath("/mm");
	}
	
//	@Bean
//	public CommonsMultipartResolver file(){
//		CommonsMultipartResolver re= new CommonsMultipartResolver();
//		re.setDefaultEncoding("utf-8");
//		re.setMaxUploadSize(10485760000l);
//		re.setMaxInMemorySize(40960);
//		return re;
//	}
}
